import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Collection;

import javax.xml.transform.Result;

import org.jaudiotagger.audio.AudioFile;
import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.exceptions.CannotReadException;
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException;
import org.jaudiotagger.audio.exceptions.ReadOnlyFileException;
import org.jaudiotagger.tag.FieldKey;
import org.jaudiotagger.tag.Tag;
import org.jaudiotagger.tag.TagException;

import de.umass.lastfm.Artist;
import de.umass.lastfm.Caller;
import de.umass.lastfm.Chart;
import de.umass.lastfm.User;
import de.umass.lastfm.Artist;

public class LastFmMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		String key = "252ccc88528cf9c5969f84c73b6a4968"; //this is the key used in the Last.fm API examples
		/*
	    String user = "loOoksha";
	    Chart<Artist> chart = User.getWeeklyArtistChart(user, 10, key);
	    DateFormat format = DateFormat.getDateInstance();
	    String from = format.format(chart.getFrom());
	    String to = format.format(chart.getTo());
	    System.out.printf("Charts for %s for the week from %s to %s:%n", user, from, to);
	    Collection<Artist> artists = chart.getEntries();
	    for (Artist artist : artists) {
	        System.out.println(artist.getName());
	    }
	    */
	    
		File file = new File("E:\\God is an Astronaut - Radau.mp3");
		AudioFile f = null;
		try {
			f = AudioFileIO.read(file);
		} catch (CannotReadException | IOException | TagException
				| ReadOnlyFileException | InvalidAudioFrameException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Tag tag = f.getTag();
		String artist = tag.getFirst(FieldKey.ARTIST);
		String title = tag.getFirst(FieldKey.TITLE);
		System.out.println(artist + " - " + title);
	    Artist info = Artist.getInfo(artist , key);
	    System.out.println("Artist INFO: " + info.getWikiSummary());
	    System.out.println("Artist INFO: " + info.getPlaycount());
	    

	}

}
